package com.lucifer.cloud.boot.blog.chat.config;

import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.QuestionAnswerAdvisor;
import org.springframework.ai.ollama.OllamaChatModel;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.ai.zhipuai.ZhiPuAiChatModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@RequiredArgsConstructor
public class ChatClientConfig {

    final OllamaChatModel model;

    final ZhiPuAiChatModel zhiPuAiChatModel;

    @Resource(name = "pgVectorStore")
    private VectorStore vectorStore;

    @Bean
    public ChatClient chatClient() {
        return ChatClient.builder(zhiPuAiChatModel)
            .defaultSystem("你是我的企业知识库AI客服助手，请帮我解答我提出的相关问题")
            .defaultAdvisors(
                new QuestionAnswerAdvisor(vectorStore)
            )
            .build();
    }


}
